package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.dto.FeedbackCreateDTO;
import com.qzsf.backend.dto.FeedbackStats;
import com.qzsf.backend.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/24 22:21 周日
 * @Email 1429278462@qq.com
 * @Remark 反馈控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("feedbacks")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;
    @GetMapping
    public Result getFeedbackByCondition(
            @RequestParam(required = false) Integer typeId,
            @RequestParam(required = false) Integer eventId,
            @RequestParam int pageNo,
            @RequestParam int pageSize){
        System.out.println();
        return feedbackService.getFeedbackByCondition(typeId, eventId, pageNo, pageSize);
    }

    @GetMapping("/stats")
    public Result getFeedbackStats(@RequestParam(required = false) Integer eventId,
                                                          @RequestParam(required = false) Integer typeId) {
        // 调用服务层获取统计数据，并返回给前端
        return feedbackService.getFeedbackStats(eventId, typeId);
    }

    @PostMapping
    public Result createUserFeedback(@RequestBody FeedbackCreateDTO feedbackCreateDTO){
        return feedbackService.createUserFeedback(feedbackCreateDTO);
    }

}
